<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<%@ include file="/WEB-INF/jspf/meta/meta.jspf"%>
<title>宿舍列表</title>
<%@ include file="/WEB-INF/jspf/adminPage.jspf"%>

</head>
<body>
	<table class="easyui-datagrid" id="dg_room" title="宿舍信息列表"
		style="width: 100%; height: 470px"
		data-options="singleSelect:false,fit:true,fitColumns:true,pagination:true,collapsible:true,toolbar:'#tb',url:'<%=request.getContextPath()%>/room/selectRoom.json',method:'get'">
		<thead>
			<tr>
				<th field="ck" checkbox="true"></th>
				<th data-options="field:'roomId',width:80,aling:'center'">宿舍编号</th>
				<th data-options="field:'roomName',width:100,aling:'center'">宿舍名称</th>
				<th data-options="field:'roomInfo',width:250,aling:'center'">宿舍备注</th>

			</tr>
		</thead>
	</table>

	<div id="tb">
		<c:if test="${code.contains('room:update')}">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"
			onclick='Roomadd()'>添加</a> <a href="#" class="easyui-linkbutton"
			iconCls="icon-edit" plain="true" onclick="RoomUpdate()">修改</a>
		</c:if>
		<c:if test="${code.contains('room:dell')}">
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true"
			onclick='dellroom()'>删除</a>
		</c:if>
	</div>
	<!-- 添加宿舍信息 -->
	<%@ include file="/WEB-INF/jsp/room/ListForAdd.jspf"%>

	<%@ include file="/WEB-INF/jsp/room/ListForUpdate.jsp"%>

	<script type="text/javascript">	
		//批量删除宿舍信息
		function dellroom(){
					var rows = $('#dg_room').datagrid('getChecked');
					if(rows.length==0){
						$.messager.show({
							title:'操作提示',
							msg:'请选择需要修改的记录，再点修改！',
							timeout:3000,
							showType:'slide'
						});
						return;
					}else{
						
						$.messager.confirm('操作提示', '确定要删除数据吗?', function(r){
							if (r){
								var ids = [];
								for(var i=0; i<rows.length; i++){
									ids.push(rows[i].roomId);
								}
								
								 $.ajax({url:"<%=request.getContextPath()%>/room/deleteRoom.json?list="+ids
										 ,success:function(data){
												$.messager.show({
													title:'操作提示',
													msg:data.msg,
													timeout:5000,
													showType:'slide'
												});
											 $('#dg_room').datagrid('reload');
								    }});
							}
						});
						
				   }
        }
	</script>
</body>
</html>